﻿
using GoodDotNet.Core.Data;
using GoodDotNet.Core.Entity;
using GoodDotNet.Core.IRepository;
using GoodDotNet.Core.Repository.BASE;

namespace GoodDotNet.Core.Repository
{
   public class  AdminRoleModuleRepository :  BaseRepository< AdminRoleModule>, AdminRoleModuleIRepository
    {
        public  AdminRoleModuleRepository(MyDbContext context) : base(context)
        {

        }
        /// <summary>
        /// 查找角色权限
        /// </summary>
        /// <param name="role">角色id</param>
        /// <returns></returns>
        public List<AdminModule> GetListByRole(int role)
        {
            var query = from a in context.AdminRoleModule
                        join b in context.AdminModule
                        on a.ModuleId equals b.Id
                        where a.RoleId == role
                        select b;
            return query.ToList();
         }

        public void Remove(int moduleId,int role)
        {
          var  m=context.AdminRoleModule.Where(a => a.ModuleId == moduleId && a.RoleId == role);

          
                context.RemoveRange(m);
           
        }
    }
 }
